import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hockey/extensions/jzx_json_extension.dart';

part 'jzx_comment_data.freezed.dart';
part 'jzx_comment_data.g.dart';

@freezed
class JzxCommentData with _$JzxCommentData {
  const factory JzxCommentData({
    /// 评论ID => 帖子ID + 基数递增
    @JzxJsonAlwaysString() @Default('') String id,

    /// 帖子ID
    @JzxJsonAlwaysString() @Default('') String postId,
    @JzxJsonAlwaysString() @Default('') String userId,
    @JzxJsonAlwaysString() @Default('') String avatar,
    @JzxJsonAlwaysString() @Default('') String nickname,
    @JzxJsonAlwaysNum() @Default(0) num level,

    /// text / voice path
    @JzxJsonAlwaysString() @Default('') String content,

    /// 0: text, 1: voice
    @JzxJsonAlwaysNum() @Default(0) num type,

    /// 留言类型 0: 帖子, 1: 短视频
    @JzxJsonAlwaysNum() @Default(0) num pageType,

    /// praise
    @JzxJsonAlwaysNum() @Default(0) num like,
    @Default(false) bool isLiked,
  }) = _JzxCommentData;

  factory JzxCommentData.fromJson(Map<String, Object?> json) =>
      _$JzxCommentDataFromJson(json);
}
